<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <!--1.width=device-width    //应用程序的宽度和屏幕的宽度是一样的
2.height=device-height  //应用程序的高度和屏幕的高是一样的
3.initial-scale=1.0  //应用程序启动时候的缩放尺度（1.0表示不缩放）
4.minimum-scale=1.0  //用户可以缩放到的最小尺度（1.0表示不缩放）
5.maximum-scale=1.0  //用户可以放大到的最大尺度（1.0表示不缩放）
6.user-scalable=no  //用户是否可以通过他的手势来缩放整个应用程序，使应用程序的尺度发生一个改变（yes/no）
    -->
    <!-- 优先使用 IE 最新版本和 Chrome -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <!-- 启用360浏览器的极速模式(webkit) -->
    <meta name="renderer" content="webkit">
    @include('partner.header')
    <link rel="stylesheet" href="/partner/plugins/webuploader-0.1.5/webuploader.css">
    <style type="text/css">
        .upbtn-pic{font-size: 12px;}
    </style>
    <title>修改资料</title>
</head>
<body>
    @if(session('rs'))
        <div class="alert alert-{{session('rs')['status']}}">
          {{ session('rs')['msg'] }}
        </div>
        @endif
<div class="inline-no-icon">
    <form class="form-inline login-form form-noborder" role="form" id="accountLogin" method="post" action="{{url('partner/modify-update?id='.$data->id)}}">
        <!--per block-->
        <div class="block-title">输入手机号获取验证码后即可重置密码</div>
        <div class="white-box">
            <div class="form-group">
                    <span class="group-select select-long">手机号
                        <select class="select-noborder">
                            <option value="">+86中国</option>
                        </select></span>
                <input type="text" class="form-control input-with-phone" placeholder="输入手机号" name="mobile" value="{{$data->mobile}}">
            </div>
            <hr class="break-form">
            <div class="form-group form-with-btn">
                <label class="control-label">验证码</label>
                <input type="text" class="form-control input-inline" placeholder="请输入6位验证码" name="validatecode">
                <button type="button" class="btn btn-verification-border"  id="getcode">获取验证码</button>
            </div>
        </div>

        <!--per block-->
        <div class="block-title">服务商信息</div>
        <div class="white-box padding-block">
            <div class="form-group">
                <label class="control-label">名称</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的服务商名称" name="name" value="{{$data->name}}" readonly="">
            </div>
            <hr class="break-form">
            <div class="form-group">
                <label class="control-label">地址</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的服务商地址" name="address" value="{{$data->address}}">
            </div>
            <hr class="break-form">
            <div class="form-group">
                <label class="control-label">电话</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的服务商电话" name="phone" value="{{$data->phone}}">
            </div>
            <hr class="break-form">
            <div class="form-group upload-box">
                <div class="per-upload">
                    <label class="control-label">门店照片</label>

                    <div class="uploader-demo" data-name="shop_pic">
                        <div class="filePicker" >
                            <img src="{{$data->shop_pic}}" alt="" class="view-pic" width="45" id="shop_pic" style="display:{{$data->shop_pic?'block':'none'}} ">
                            <button type="button"  class="btn font-normal upbtn-pic">上传</button></div>
                    </div>
                </div>
                <div class="per-upload">
                    <label class="control-label">营业执照</label>
                    <div class="uploader-demo" data-name="zhizhao_pic">
                    <div class="filePicker" >
                        <img src="{{$data->zhizhao_pic?$data->zhizhao_pic:''}}" alt="" class="view-pic" width="45" id="zhizhao_pic" style="display:{{$data->zhizhao_pic?'block':'none'}} ">
                        <button type="button"  class="btn font-normal upbtn-pic">上传</button></div>
                </div>
                </div>
            </div>
        </div>

        <!--per block-->
        <div class="block-title">收款信息(选填)</div>
        <div class="white-box padding-block">
            <div class="form-group">
                <label class="control-label">银行/平台</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的收款银行或支付平台" name="money_platform" value="{{$data->money_platform}}">
            </div>
            <hr class="break-form">
            <div class="form-group">
                <label class="control-label">户名</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的户名" name="account_name" value="{{$data->account_name}}">
            </div>
            <hr class="break-form">
            <div class="form-group">
                <label class="control-label">卡号/账号</label>
                <input type="text" class="form-control input-inline" placeholder="请输入您的收款卡号或支付账号" name="account_number" value="{{$data->account_number}}">
            </div>
            <hr class="break-form">
        </div>

        <button type="submit" class="btn btn-full-green font-normal">提交资料</button>
        <input name="shop_pic" value="{{$data->shop_pic}}"    type="hidden" /> 
        <input name="zhizhao_pic" value="{{$data->zhizhao_pic}}" type="hidden" /> 
        {{csrf_field()}}
    </form>
</div>

@include('partner.footer')
<!--webuploader-->
<script src="/partner/plugins/webuploader-0.1.5/webuploader.js"></script>

<script>
    var picname;

    var countdown = 60;
   $('.uploader-demo').on('click',function(){
    picname = $(this).data('name');
   })
   

    //上传
    // 初始化Web Uploader
    var uploader = WebUploader.create({

        // 选完文件后，是否自动上传。
        auto: true,

        // 选择文件的按钮。可选。
        // 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: '.filePicker',
        // swf文件路径
        //swf: BASE_URL + '/js/Uploader.swf',

        // 上传文件数量限制
        fileNumLimit: 8,

        // 文件接收服务端。
        server: '{{url('partner/upload')}}',//上传接口

        // 只允许选择图片文件。
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/*'
        },
        formData:{
            _token:'{{csrf_token()}}'           

        }
    });

    // uploader.on('startUpload',function(){
    //     alert(picname);
    // });
    //上传成功后显示上传照片
    uploader.on('uploadSuccess', function (file, response) {

        //预览图片
        console.info(response);
        // $(el).find('.upbtn-pic').hide();
        $('#'+picname).attr('src',response.file)
        $('#'+picname).css('display','block')
        $('input[name="'+picname+'"]').val(response.file);


    })


    $('#getcode').on('click',function(){
        var _this = $(this);
        var url = "{{url('partner/send-sms')}}";
        var data = {};
        data.mobile = $('input[name="mobile"]').val();
        if(checkPhone(data.mobile)==false) {
            alert('手机号码格式错误');
            return false;
        }
        $.get(url,data,function(rs){
            console.info(rs);
            setTime(_this);
        });
    })
    
    
    function setTime(obj) {
        if (countdown == 0) {
            obj.prop('disabled', false);
            obj.text("获取验证码");
            countdown = 60;//60秒过后button上的文字初始化,计时器初始化;
            return;
        } else {
            obj.prop('disabled', true);
            obj.text("再次获取("+countdown+"s)") ;
            countdown--;
        }
        setTimeout(function() { setTime(obj) },1000) //每1000毫秒执行一次

       
    }
</script>
</body>
</html>